sudo mkdir -p /tmp/tmp-ro /tmp/tmp-rw /tmp/tmp-aufs
cd /media/sude/7E13-0890/casper/
sudo mount -o loop /media/sude/7E13-0890/casper/filesystem.squashfs /tmp/tmp-ro
sudo mount /dev/sda1 /tmp/tmp-rw/
#sudo mount -o loop /media/sude/7E13-0890/casper-rw /tmp/tmp-rw/
sudo mount -t aufs -o br:/tmp/tmp-rw:/tmp/tmp-ro none /tmp/tmp-aufs/
cd /tmp/tmp-aufs
#tar xvpf /media/sude/7E13-0890/restore-to-base-etc.tar 


mkdir /tmp/image
cd /tmp/image

sudo mksquashfs /tmp/tmp-aufs/ /media/sude/mata-intern/live-cd-casper-script/filesystem.squashfs
sudo chroot /tmp/tmp-aufs/ dpkg-query -W --showformat='${Package} ${Version}\n'  > /media/sude/mata-intern/live-cd-casper-script/filesystem.manifest
history
cp /media/sude/mata-intern/live-cd-casper-script/filesystem.manifest /media/sude/mata-intern/live-cd-casper-script/filesystem.manifest-desktop
sed -i -e '/ubiquity/d' -e '/casper/d' /media/sude/mata-intern/live-cd-casper-script/filesystem.manifest-desktop
history
sudo umount /tmp/tmp-aufs 
sudo umount /tmp/tmp-rw
sudo umount /tmp/tmp-ro
sudo mount -o loop /media/sude/mata-intern/live-cd-casper-script/filesystem.squashfs /tmp/tmp-ro
sudo printf $(sudo du -sx --block-size=1 /tmp/tmp-ro | cut -f1) > /media/sude/mata-intern/live-cd-casper-script/filesystem.size
sudo umount /tmp/tmp-ro 
sudo rmdir /tmp/tmp-ro/
sudo rmdir /tmp/tmp-rw
sudo rmdir /tmp/tmp-aufs/
cp /media/sude/mata-intern/live-cd-casper-script/* /media/sude/7E13-0890/casper/
sync
